home *** CD-ROM | disk | FTP | other *** search
- /*
- File: TMP_Config.h
-
- Contains: Template configuration structures
-
- To Do:
- */
-
- #ifndef __TMP_CONFIG__
- #define __TMP_CONFIG__
-
- #ifdef __cplusplus
- #ifndef __OPENTPTPRIVETNEW__
- #include <OpenTptPrivateNew.h>
- #endif
- #endif
- #ifndef __OPENTPTCLIENT__
- #include <OpenTptClient.h>
- #endif
- #ifndef __STROPTS__
- #include <stropts.h>
- #endif
-
- #if GENERATING68K
- #define TMPCONFIG_USES_CFM 0
- #define TMPCONFIG_USES_ASLM 1
- #else
- #define TMPCONFIG_USES_CFM 1
- #define TMPCONFIG_USES_ASLM 0
- #endif
-
- /*******************************************************************************
- ** Some constants
- **
- ** You need to change these IDs!!!
- ** We use the name "configurator" for the resident portion of your configurator,
- ** and the name "controller" for non-resident portion that is loaded into
- ** memory when someone uses your protocol or driver.
- ********************************************************************************/
-
- #define kMyEvent1 kPRIVATEEVENT + 1
- #define kMyEvent2 kPRIVATEEVENT + 2
- #define kMyNoClientEvent kPRIVATEEVENT + 3
-
- #define kMyResourceID 128 /* Our STR# resource */
- #define kEvent1ID 1 /* Index for event in STR# resource */
- #define kEvent2ID 2
-
- /*
- * These are the IDs we need to use when we first plumb a stream (i.e. we
- * have nothing to clone yet.
- */
- #define kTMPCreateConfigASLMID kOTClientPrefix "TMPCreateCfig"
- #define kTMPCreateConfigCFMID "OTTMPConfigCreateLib"
- /*
- * This is the ID of the resident code
- */
- #define kTMPRSConfigASLMID kOTClientPrefix "TMPCfigor"
- #define kTMPRSConfigCFMD "OTTMPConfigurator"
- /*
- * This is the ID of the non-resident code
- */
- #define kTMPConfigASLMID kOTClientPrefix "TMPCntrlr"
- #define kTMPConfigCFMMID "OTTMPController"
- /*
- * Timeout to unload
- */
- enum
- {
- kMyUnloadTimeout = 5 * 1000
- };
-
- /*
- * MIOC_CFIG is the IOCTL base used to send configuration data to yourself. You
- * don't have to use it - you can use transparent IOCTLs, but this is more
- * convenient.
- */
- enum
- {
- kMyConfigureIoctl = MIOC_CMD(MIOC_CFIG, 0)
- };
-
- /*******************************************************************************
- ** Some Structures
- ********************************************************************************/
-
- struct AConfiguration;
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=mac68k
- #endif
-
- /*
- * This structure is what we use when we create a state machine.
- * It includes all the extra information we need in order to plumb
- * the link or protocol.
- */
- typedef struct TMPOpenInfo TMPOpenInfo;
- typedef struct AConfiguration AConfiguration;
-
- struct TMPOpenInfo
- {
- OTLink fLink;
- AConfiguration* fConfig; /* Our configuration structure */
- OTStateMachine* fStateMachine; /* The state machine we're using */
- StreamRef fTheStream; /* The current stream being worked on */
- OTNotifyProcPtr fNotifyProc; /* So we can install the right function */
- OTConfiguration* fCfig; /* Configuration we're creating */
- OTConfiguration* fToPush; /* Configuration to push */
- struct strioctl fIoctlInfo; /* A place for I_STR Ioctls to have */
- OTOpenFlags fOpenFlags; /* The original Open flags */
- OSErr fSavedError; /* Place to save error as we unwind */
- #if TMPCONFIG_USES_CFM
- UInt32 fCreateID; /* CFM ID, if needed */
- #endif
- };
-
- typedef struct MySharedStruct MySharedStruct;
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- typedef void (*UnloadSelfProcPtr)(void);
- typedef OSStatus (*CreateMyConfigProcPtr)(MySharedStruct*);
-
- #ifdef __cplusplus
- }
- #endif
-
- /*
- * This structure is shared between our "controller" and our "configurator".
- */
- struct MySharedStruct
- {
- UnloadSelfProcPtr scheduleUnloadProc; /* Procedure to schedule unload */
- OTProcessProcPtr unloadProc; /* Procedure to do unload Now */
- TOTConfigurator* cfig; /* The configurator */
- long systemTask; /* System task for unloading */
- };
-
- /*******************************************************************************
- ** Preferences (if applicable)
- ********************************************************************************/
-
- enum
- {
- kTMPPrefsVersion = 1,
- kTMPNumPrefs = 3
- };
-
- struct MyPreferences
- {
- UInt16 fVersion;
- UInt16 fNumPrefs;
- OTPortRef fPort;
- OTLink fLink;
- void* fPrefs[kTMPNumPrefs];
- };
-
- typedef struct MyPreferences MyPreferences;
-
- struct Prot1Prefs
- {
- UInt16 fVersion;
- UInt16 fSize;
- UInt32 fMyAddress;
- Boolean fIsFixed;
- };
-
- typedef struct Prot1Prefs Prot1Prefs;
-
- struct Prot2Prefs
- {
- UInt16 fVersion;
- UInt16 fSize;
- OTTimeout fDefaultTimeout;
- };
-
- typedef struct Prot2Prefs Prot2Prefs;
-
- struct Prot3Prefs
- {
- UInt16 fVersion;
- UInt16 fSize;
- UInt32 fRetryCount;
- OTTimeout fRetryTimeout;
- };
-
- typedef struct Prot3Prefs Prot3Prefs;
-
- /*******************************************************************************
- ** Struct AConfiguration
- ********************************************************************************/
-
- enum
- {
- kIsBeingCreated = 0, /* Currently creating configuration */
- kIsUnused = 1, /* Configuration is currently unused */
- kIsScheduled = 2, /* Configuration is scheduled for unload */
- kIsInUse = 3 /* Configuration is in use */
- };
-
- struct AConfiguration
- {
- OTLink fMyLink; /* To link configurations together */
- StreamRef fCtlStream; /* The control stream */
- StreamRef fHelperStream; /* The stream with our helper module on it */
- OTPortRef fLinkID; /* The portref of this stream */
- OTPortRef fOurID; /* The portref of our network layer */
- long fTimerTask; /* A timer task to use with this config */
- long fSystemTask; /* A system task to use with this config */
- /* Name of a helper module we had to register */
- /* as part of our plumbing */
- MyPreferences* fPrefs; /* Pointer to our prefs structure */
- char fNetworkName[kMaxModuleNameSize];
- UInt8 fStatus; /* Status variable so we know where we are */
- };
-
- /*******************************************************************************
- ** MyGlobal structure
- ********************************************************************************/
-
- struct MyGlobal
- {
- OTList fConfigs; /* List of configurations */
- UInt32 fMyMask;
- };
-
- typedef struct MyGlobal MyGlobal;
-
- /*******************************************************************************
- ** CLASS TMyConfigurator
- ********************************************************************************/
-
- /*
- * This enum is gives the "index number" of the protocols that we support
- */
-
- enum
- {
- kProt1ID = 0,
- kProt2ID, kProt3ID
- };
-
- enum
- {
- kProt1PrefsIndex = 1, kProt2PrefsIndex, kProt3PrefsIndex
- };
-
- /*
- * This defines the list of protocols we support, in the same order
- * as the enum above.
- */
- #define kProtocolList "Prot1", "Prot2", "Prot3"
-
- struct TMPConfigurator
- {
- MyGlobal* fGlobal; /* Pointer to my global variables list */
- MySharedStruct* fShared; /* Pointer to the shared structure */
- TMPOpenInfo* fList; /* List of outstanding open requests */
- OTGate fGate; /* Gate to synchronize stream opening */
- Boolean fDontUnload; /* Boolean to tell us to not unload */
- Boolean fShuttingDown; /* Flag that we're shutting down */
- };
-
- typedef struct TMPConfigurator TMPConfigurator;
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=reset
- #endif
-
- #endif
-